/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sadhar.sipp.itembiaya;

import java.util.Map;
import org.sadhar.errhandler.ClassAntiNull;
import org.zkoss.zul.Listbox;
import org.sadhar.sia.framework.ClassApplicationModule;

import org.zkoss.zul.Label;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

/**
 *
 * @author Yohan Hardinugroho
 */
public class ItemBiayaPopupOnPerekamanAnggaranBiayaUnitNonRapatKerjaWnd extends ClassApplicationModule {

    private Listbox lstboxItemBiaya;

    public ItemBiayaPopupOnPerekamanAnggaranBiayaUnitNonRapatKerjaWnd() {
    }

    public void onCreate() throws Exception {
        lstboxItemBiaya = (Listbox) getFellow("lstboxItemBiaya");

    }

    public void lstboxItemBiayaOnSelect() throws Exception {
        Window w = (Window) this.getParent();
        Textbox txtboxItemBiayaSearchP = (Textbox) w.getFellow("txtboxItemBiayaSearch");
        Textbox txtboxIdItemBiaya = (Textbox) w.getFellow("txtboxIdItemBiaya");
        Textbox txtboxItemBiaya = (Textbox) w.getFellow("txtboxItemBiaya");
        Label lblSatuan = (Label) w.getFellow("lblSatuan");
        Map m = (Map) lstboxItemBiaya.getSelectedItem().getValue();
        int kode = 0;
        if (m.get("kodeItem") != null) {
            kode = ClassAntiNull.AntiNullInt(m.get("kodeItem"));
        } else if (m.get("idBarang") != null) {
            kode = ClassAntiNull.AntiNullInt(m.get("idBarang"));
        }


        String nama = "";
        if (m.get("namaItem") != null) {
            nama = ClassAntiNull.AntiNullString(m.get("namaItem"));
        } else if (m.get("namaBarang") != null) {
            nama = ClassAntiNull.AntiNullString(m.get("namaBarang"));
        }


        txtboxIdItemBiaya.setValue("" + kode);
        txtboxItemBiayaSearchP.setValue(nama);
        txtboxItemBiaya.setValue(nama);

        if (m.get("satuan") != null) {
            lblSatuan.setValue(ClassAntiNull.AntiNullString(m.get("satuan")));
        }
        this.detach();
    }
}
